<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        const colors = {
            red:Symbol(),
            green:Symbol(),
            pink:Symbol(),
            blue:Symbol()
        }
        //默认处于红色
        var color = colors.red
        var box = document.querySelector('#box')
        box.onclick = function () {
            switch (color) {
                case colors.red:
                    box.style.backgroundColor = 'green'
                    color = colors.green
                    break
                case colors.green:
                    box.style.backgroundColor = 'pink'
                    color = colors.pink
                    break
                case colors.pink:
                    box.style.backgroundColor = 'blue'
                    color = colors.blue
                break
                case colors.blue:
                    box.style.backgroundColor = 'red'
                    color = colors.red
                break

            }
        }

    </script>
</body>
</html>